import { getSetting } from '@/api/login';
import storage from '@/utils/storage';
const systemStore: any = {
    namespaced: true,
    state() {
        return {
            info: storage.get('app_info'),
        };
    },
    mutations: {
        SET_INFO: (state: any, data: any) => {
            state.info = data;
            storage.set('app_info', data);
        },
    },

    actions: {
        settingDetail({ commit }: any) {
            return new Promise((resolve, reject) => {
                getSetting()
                    .then((response: any) => {
                        const { data } = response;
                        commit('SET_INFO', data);
                        resolve(data);
                    })
                    .catch((error: any) => {
                        reject(error);
                    });
            });
        },
    },
};

export default systemStore;
